<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@page import="wt.httpgw.URLFactory"%>
<%
String baseUrl = new URLFactory().getBaseHREF();
%>
<head>
<title>创建文档</title>
</head>
<body>


<center>
<div style="display: none">
<div style="margin:10px 0;"></div>
	<div  iconCls="icon-kms-related" title="创建文档" style="width: 650px; height: 400px; padding: 5px;" id="createDoc" name="createDoc" >
		<div style="padding:10px 0 10px 60px">

<form action="" method="post" enctype="multipart/form-data" name="docForm" id="docForm">
  <table>
  	<tr>
      <td>主要内容</td>
      <td>
        <input  type="file" id="inp_primary" name="inp_primary"  size="45" onchange="setName()"/>
      </td>
    </tr>
    <tr>
      <td style="width:100px">*名称</td>
      <td>
        <input class="easyui-validatebox" data-options="required:true" name="docName" id="docName" type="text" size="45" />
      </td>
    </tr>
    <tr>
      <td >说明</td>
      <td>
        <textarea name="desc" id="desc" cols="45" rows="5"></textarea>
      </td>
    </tr>
    <tr>
      <td colspan="2">
            <br/>
          附件：<a href="javascript:void(0)" onclick="addAppendix('appendixFileId')">添加附件</a>
               </td>
    </tr>
     <tr>
                <td colspan="2">
                <div id="appendixFileId"></div>
                </td>
				
            </tr>
    <tr>
      <td><input id="ffolderPath" name="ffolderPath" type="hidden"
			value="/Default/"></input></td>
      <td align="center"><label>
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()">提交</a>
	    	<a href="javascript:void(0)" class="easyui-linkbutton" onclick="cancle1()">关闭</a>
      </label></td>
    </tr>
  </table>
</form>
</div>
</div>
</div>
</center>
<script type="text/javascript">
	function setName()
	{
		var value=document.getElementById("inp_primary").value;
		var docValue=value.substring(value.lastIndexOf("\\")+1,value.lastIndexOf(".")); 
		document.getElementById("docName").value=docValue;
	}
	function submitForm(){
		var node = $('#folderTree').tree('getSelected');
		var path=getFullPath(node)+"/";
		document.getElementById("ffolderPath").value=path;
	 var docName=document.getElementById("docName").value;
	 if(docName==""||docName==null)
	 {
		 alert("名称不能为空");
		 return;
	}
		
	$('#docForm').submit()
	}
	function clearForm(){
	$('#docForm').form('clear');
	}
	/*添加附件功能*/
	function addAppendix(htmlId){
		//alert("appendixFileId :"+htmlId);
		var $div = $("#"+htmlId);
		var len = $div.children("input[type='file']") + 1;
		//alert("len :"+len);
		$div.append("<div><input type='file' size=60 name='appendixFile_"+len+"' /><input type='button' value='-' onclick='removeAppendix(this)'></input></div>");
	}
	function removeAppendix(obj){
		var temp = $(obj);
		temp.parent("div").remove(); 
	}
	
	function initCreateQues(){
		$("#docForm").form({
			url:'<%=baseUrl%>shmged/jsp/com/shlcm/documents/jspCreateDocument.jsp',
			onSubmit:function (){
			},
			success:function (data){
				//alert(data);
				if(data.indexOf("ERROR") != -1){
					$.messager.alert('提示', data);
					cancle1();
				}else{
					var oid=data.split("__");
					$.messager.alert('提示',oid[0]);
					cancle1();
					addTab("","",oid[1],oid[2]);
				}
				hideProcessMsg("prince_process_ques");
			},
			onLoadError:function (){
				hideProcessMsg("prince_process_ques");
			}
		});
	}

	function createDoc(){
		  $('#createDoc').window({
			     collapsible:false,
			     minimizable:false,
			     maximizable:false,
			     resizable:false,
				 width:800,
			     height:400,
			     modal:true,
			     left:300,
			     onClose:function(){
			  	 refe();
			  	 $('#createDoc').window("destroy");
			     }
			 });
	}

	function cancle1(){
		
		$('#createDoc').window('close');
		
	}
	initCreateQues();
</script>
</body>

</html>


